package gcj2008.qual;


import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;

import common.AbstractRunner;
import common.AbstractRunner.SIZE;

public class A extends AbstractRunner {
	
	
	@Override
	public void handleCase(int caseNumber) throws Exception {		
		int s = scanner.nextInt();		
		scanner.nextLine();
		HashMap<String,Integer> engines = new HashMap<String,Integer>(100);		
		for (int i=0; i<s; i++) engines.put(scanner.nextLine(), i);
		
		int q = scanner.nextInt();
		scanner.nextLine();
		boolean[] tmp = new boolean[s];
		int cnt = s;
		int res = 0;
		for (int i=0; i<q; i++) {
			Integer idx = engines.get(scanner.nextLine());			
			if (idx != null && cnt == 1 && !tmp[idx]) {
				res ++;
				Arrays.fill(tmp, false);
				cnt = s-1;
				tmp[idx] = true;
			} else if (!tmp[idx]){
				tmp[idx] = true;
				cnt --;
			}
		}
		
		out.write(Integer.toString(res)+"\n");
	}
	
	public static void main(String[] args) throws Exception {
		new A().init(SIZE.large).execute();
	}
}
